/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package horizon.component;

import horizon.collision.CollisionBox;
import horizon.collision.CollisionManager;
import horizon.util.Vector2;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;


public class CollisionComponent extends Component{

    public CollisionBox box;
    CollisionManager c;
    public Vector2 lastPos = new Vector2(0 , 0);
    
    public CollisionComponent(String id , CollisionManager c){
        super(id);
        
        box = new CollisionBox(new Rectangle(new Point(0 , 0) , new Dimension(1 , 1)));
        this.c = c;
        
    }
    
    
    
    @Override
    public void update(long elapsedTime) {
        
        box.getBox().x = (int)this.owner.getPosition().getX();
        box.getBox().y = (int)this.owner.getPosition().getY();
        
    }
    
    public boolean CheckCollisions(CollisionComponent c){
        
        if(box.getBox().intersects(c.box.getBox())){
            
            return true;
            
        }
        else{
            
            return false;
            
        }
        
    }
    
    public void setCollisionManager(CollisionManager c){
        
        this.c = c;
        
    }
    
}
